{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=842
  Verdict: Accepted
}
{$APPTYPE CONSOLE}
{$R+,S+,Q+,I+,O-}
uses SysUtils;
var n,i:longint; x,p,k:int64;
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
readln(n);
p:=1;
x:=1;
if (n=1) then write(1) ELSE begin
  for i:=2 to n do begin
    k:=(p+x) mod 10;
    x:=p;
    p:=k;
  end;
  write(k);
end;
end.